﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DB;

namespace Restarty_SIPO3
{
    public partial class NastaveniaWindow : Form
    {
        nastavenia nastav = new nastavenia();
        public NastaveniaWindow()
        {
            prihlasenieNaDB databaza = new prihlasenieNaDB();
            InitializeComponent();

            tbDatabaza.Text = databaza.getDatabase();
            tbHeslo.Text = databaza.getPasswor(0);
            tbServer.Text = databaza.getHost();
            tbUzivatel.Text = databaza.getLogin(0);
            
            nudOneskorenie.Value = (decimal)nastav.TimeOut;
            nudOpakovanie.Value = (decimal)nastav.RepeatCount;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            prihlasenieNaDB databaza = new prihlasenieNaDB();
            databaza.ulozNastavenieParametrov(tbServer.Text, tbDatabaza.Text, tbUzivatel.Text, tbHeslo.Text,0);
            databaza.databaza = tbDatabaza.Text;
            databaza.Heslo = tbHeslo.Text;
            databaza.host = tbServer.Text;
            databaza.Meno = tbUzivatel.Text;
            nastav.TimeOut = (int)nudOneskorenie.Value;
            nastav.RepeatCount = (int)nudOpakovanie.Value;
            nastav.Save();
        }
    }
}
